// 抽象动物类，定义了动物共有的基本属性和抽象行为
abstract class Animal {
    protected String name;
    protected String species;
    protected String breed;
    protected double price;

    public Animal(String name, String species, String breed, double price) {
        this.name = name;
        this.species = species;
        this.breed = breed;
        this.price = price;
    }

    // 抽象方法，定义动物吃饭的行为，由具体子类实现
    abstract void eat();

    // 抽象方法，定义动物睡觉的行为，由具体子类实现
    abstract void sleep();

    // 抽象方法，定义动物玩耍的行为，由具体子类实现
    abstract void play();

    // 抽象方法，定义动物发出叫声的行为，由具体子类实现
    abstract void makeSound();
}

// 猫类，继承自动物类，实现了猫特有的行为逻辑
class Cat extends Animal {
    public Cat(String name, String species, String breed, double price) {
        super(name, species, breed, price);
    }

    @Override
    void eat() {
        System.out.println(name + " the cat is eating.");
    }

    @Override
    void sleep() {
        System.out.println(name + " the cat is sleeping.");
    }

    @Override
    void play() {
        System.out.println(name + " the cat is playing.");
        makeSound();
    }

    @Override
    void makeSound() {
        System.out.println("Meow!");
    }
}

// 狗类，继承自动物类，实现了狗特有的行为逻辑
class Dog extends Animal {
    public Dog(String name, String species, String breed, double price) {
        super(name, species, breed, price);
    }

    @Override
    void eat() {
        System.out.println(name + " the dog is eating.");
    }

    @Override
    void sleep() {
        System.out.println(name + " the dog is sleeping.");
    }

    @Override
    void play() {
        System.out.println(name + " the dog is playing.");
    }

    @Override
    void makeSound() {
        System.out.println("Woof!");
    }
}

public class Main {
    public static void main(String[] args) {
        // 实例化动物列表，包含两只猫和两只狗
        Animal[] animals = {
                new Cat("Kitty", "Cat", "Persian", 500.0),
                new Cat("Tom", "Cat", "Siamese", 400.0),
                new Dog("Buddy", "Dog", "Labrador", 800.0),
                new Dog("Max", "Dog", "German Shepherd", 900.0)
        };

        // 遍历动物列表，调用每个动物的行为方法
        for (Animal animal : animals) {
            animal.eat();
            animal.sleep();
            animal.play();
            if (animal instanceof Dog) {
                ((Dog) animal).makeSound();
            } else if (animal instanceof Cat) {
                ((Cat) animal).makeSound();
            }
        }
    }
}